﻿Imports System
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Text
Imports System.Xml
Public Class rss
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        Response.Clear()
        Response.ContentType = "text/xml"

        Dim xtw As New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
        xtw.WriteStartDocument()
        Dim processtext As String = "type=""text/xsl"" href=""rss.xsl"""
        xtw.WriteProcessingInstruction("xml-stylesheet", processtext)
        xtw.WriteStartElement("rss")
        xtw.WriteAttributeString("version", "2.0")
        xtw.WriteStartElement("channel")
        xtw.WriteElementString("title", "Top three Karachi Biryani Recipe")
        xtw.WriteElementString("link", "http://www.yourwebsite.com/")
        xtw.WriteElementString("description", "Recipies")

        Dim objBl = New BL()
        Dim dbconn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("/App_Data/KitchenCompition.mdb"))
        Dim strSelect As String = "select top 3 * from reciepe order by currentrating desc"
        Dim dt As New DataTable()
        dt = objBl.GetDataAccess(strSelect, dbconn)

        If dt.Rows.Count > 0 Then
            For i As Integer = 0 To dt.Rows.Count - 1
                xtw.WriteStartElement("item")
                xtw.WriteElementString("title", dt.Rows(i)("RecipeName").ToString())
                xtw.WriteElementString("description", dt.Rows(i)("Recipe").ToString())
                xtw.WriteElementString("link", "http://www.yourwebsite.com/" & dt.Rows(i)("Pic").ToString())
                xtw.WriteElementString("pubDate", dt.Rows(i)("currentrating").ToString())
                xtw.WriteEndElement()
            Next
        End If

        xtw.WriteEndElement()
        xtw.WriteEndElement()
        xtw.WriteEndDocument()

        xtw.Flush()
        xtw.Close()
        
    End Sub
End Class

